package com.gyyx.transfer.service;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baidu.unbiz.easymapper.MapperFactory;
import com.gyyx.transfer.po.UserMysql;
import com.gyyx.transfer.po.UserMysql2;

@Service("JobExecuter")
public class JobExecuter {
	@Autowired
	ImportService importService;
	@Autowired
	ExportService exportService;
	private static final Logger LOGGER = LoggerFactory.getLogger(JobExecuter.class);

	public int executer() {
		List<UserMysql> list = exportService.getAlldata();
		int count = 0;
		for (UserMysql userMysql : list) {
			LOGGER.info("" + list.size());
			UserMysql2 userMysql2 = MapperFactory.getCopyByRefMapper().mapClass(UserMysql.class, UserMysql2.class)
					.registerAndMap(userMysql, UserMysql2.class);
			int rcd = importService.saveUser(userMysql2);
			if (rcd > 0) {
				count++;
			}
		}
		LOGGER.info("【执行完毕{}条】", count);
		return count;
	}
}
